package com.htsk.city.services.wechat.controller;

import cn.hutool.json.JSONObject;
import com.htsk.city.services.core.domain.City;
import com.htsk.city.services.core.domain.ServiceCategory;
import com.htsk.city.services.core.entity.R;
import com.htsk.city.services.core.entity.ServiceSubCategoryVO;
import com.htsk.city.services.wechat.service.CityService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("service")
public class ServiceController {

    @Resource
    private CityService cityService;

    /**
     * 城市接口
     * @return
     */
    @GetMapping("listCity")
    public R<List<City>> list(){
        return cityService.listCity();
    }


    @GetMapping("category")
    public R<List<ServiceCategory>> getCityService(@RequestParam("cityId") Long cityId){
        return cityService.getCityService(cityId);
    }

    @GetMapping("subCategory")
    public R<List<Map<String,Object>>> getSubService(@RequestParam("cityId") Long cityId, @RequestParam("serviceCategoryId")Long serviceCategoryId){
        return cityService.getCitySubService(cityId,serviceCategoryId);
    }

    @GetMapping("detail")
    public R<ServiceSubCategoryVO> serviceDetail(@RequestParam("cityServiceId") Long cityServiceId){
        return cityService.serviceDetail(cityServiceId);
    }

}
